lib: Fix some logic/error-checking code
authorJonathan Lebon <jonathan@jlebon.com>
Wed, 25 Jul 2018 21:51:01 +0000 (17:51 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 26 Jul 2018 21:01:19 +0000 (21:01 +0000)
commit968e8805b0dd4afbcb25db312f53584b0ec59931
tree3b84bad610b95feb90a08b1a7f0b548987996042
parentfcd31a195be0e48709ff44b24ed3b5dc2f4f60e3
lib: Fix some logic/error-checking code

Using `MAX(0, $x)` here is useless since we're comparing against an
unsigned integer. Just unpack this and only subtract if it's safe to do
so.

Also, explicitly check for `fd >= 0` rather than just `!= -1` to be sure
it's a valid fd. And finally, explicitly check the return value of
`g_input_stream_read_all` as is done everywhere else in the tree and
make it clear that we're purposely ignoring the return value of `_flush`
here, but not in other places.

Discovered by Coverity.

Closes: #1692
Approved by: cgwalters
src/libostree/ostree-repo.c
src/libotutil/ot-gpg-utils.c